/**
 * Created by apple on 16/5/30.
 */

class Service {
    constructor(CommonService) {
        "ngInject"

        this.CommonService = CommonService;

        this.uriMap = {
            getPost   : "/system_post/query/sysUserId",
            setPost   : "/system_post/set/sysPostId",
            getUserMsg: "/system_post/getSysMgrInfo",
            permission: "/permission/func_comp",
            menuUser  : "/permission/menu_tree",
            logOut    : "/logout",
            updatePwd : "/system_user/update/password"
        };

        this.page = {
            perPage : 8
        }
    }

    setPost (params) {
        params = params || {};
        return this.CommonService.request({
            url: this.uriMap['setPost'],
            params: params,
            method: "GET"
        })
    }

    getPostList(params) {
        params = params || {};
        return this.CommonService.request({
            method: "GET",
            url: this.uriMap['getPost'],
            params: params
        })
    }

    getUserMsg(params) {
        return this.CommonService.request({
            url: this.uriMap['getUserMsg'],
            params: params
        })
    }

    permission(params) {
        return this.CommonService.request({
            url: this.uriMap['permission'],
            params: params
        })
    }

    getMenuUser(params) {
        return this.CommonService.request({
            method: "GET",
            url: this.uriMap['menuUser'],
            params: params
        })
    }

    updatePassword (params) {
        params = params || {};
        return this.CommonService.request({
            method: "POST",
            url   : this.uriMap[ 'updatePwd' ],
            data: params
        })
    }

    logout () {
        return this.service.request({
            method: "GET",
            url : this.uriMap['logOut']
        })
    }

    static factory() {
        "ngInject"
        return new Service()
    }
}

export default Service;